<template>
  <div>
    <sec-form :formData="formData" :ruleForm="ruleForm" :optionData="optionData"></sec-form>
  </div>
</template>

<script>
import { getItemSceneTypeApi } from "api/configApi";
export default {
  name: "",
  props: {},
  components: {},
  data() {
    return {
      optionData: {
        auditType: this.$store.state.dictionary["auditType"],
        scene: [],
      },
      ruleForm: { auditType: "all", scene: [] },
    };
  },
  created() {
    this.formData = [
      {
        type: "radio",
        label: "审计类型",
        prop: "auditType",
        change: () => {
          this.getAuditScene();
        },
      },
      { type: "checkbox", label: "审计项", prop: "scene" },
    ];
    this.getAuditScene();
  },
  mounted() {},
  methods: {
    getAuditScene() {
      this.ruleForm.scene = [];
      getItemSceneTypeApi({ type: this.ruleForm.auditType }).then((res) => {
        let data = res.data;
        data?.forEach((item) => {
          item["label"] = item.name;
        });
        this.optionData.scene = data || [];
      });
    },
    getData() {
      let data = JSON.parse(JSON.stringify(this.ruleForm));
      data.scene = data.scene ? data.scene.join(",") : "";
      return data;
    },
  },
};
</script>
<style scoped lang="scss"></style>
